#include "global.h"


bank3 unsigned char error_list[MaxStoredError+1];
bank3 unsigned char error_counter=0;


static bank3 unsigned char el_window=0;
static bank3 unsigned int el_window_time_counter=0;

	
void CheckForRuntimeError(void)
{	
	
	if (MyODU.Data.ODUBasicData.OOprInFlt)
	{
		if (error_list[error_counter] !=  (MyODU.Data.ODUBasicData.OOprLstFlr&0b00011111))
		{	
			if ((error_counter+=1)>MaxStoredError) error_counter=MaxStoredError;
			error_list[error_counter]= (MyODU.Data.ODUBasicData.OOprLstFlr&0b00011111);
		}
	}
}

void DisplayResult (void)
{
	unsigned char dr_temp;

	
		if (error_counter)
		{
				dr_temp = (error_counter-1)/3;
				if (el_window_time_counter++ > 300)
				{	
					el_window_time_counter=0;
					if (++el_window >= dr_temp ) el_window=0;
					ClearLCD();
				};
			
				CursorPosLCD(1,0); 
				printf ("TEST FAILED   page %d",el_window+1);
				
				switch (el_window)
				{
					case 0:		CursorPosLCD(2,0);
								printf("%s", Error_explanation[error_list[1]]);
								CursorPosLCD(3,0); 
								printf("%s", Error_explanation[error_list[2]]);
								CursorPosLCD(4,0);
								printf("%s", Error_explanation[error_list[3]]);
						break;

					case 1:		CursorPosLCD(2,0);
								printf("%s", Error_explanation[error_list[4]]);
								CursorPosLCD(3,0); 
								printf("%s", Error_explanation[error_list[5]]);
								CursorPosLCD(4,0);
								printf("%s", Error_explanation[error_list[6]]);
						break;

					case 2:		CursorPosLCD(2,0);
								printf("%s", Error_explanation[error_list[7]]);
								CursorPosLCD(3,0); 
								printf("%s", Error_explanation[error_list[8]]);
								CursorPosLCD(4,0);
								printf("%s", Error_explanation[error_list[9]]);
						break;

					case 3:		CursorPosLCD(2,0);
								printf("%s", Error_explanation[error_list[10]]);
								CursorPosLCD(3,0); 
								printf("%s", Error_explanation[error_list[11]]);
								CursorPosLCD(4,0);
								printf("%s", Error_explanation[error_list[12]]);
						break;
					default:
						break;
				}; // end of case

		}
		else
		{
				CursorPosLCD(1,0); 
				printf ("     TEST PASSED    ");
		
		}

}
		












